<?php

namespace app\common\model;

use think\Model;

class TaskModel extends Model
{
    protected $autoWriteTimestamp = 'datetime';

    protected $updateTime = 'motified_time';

    // 跳转页面标识
    const PAGE_TAG_CATE = [
        1 => '直播列表',
        2 => '个人资料',
        3 => '鹰眼页面',
        4 => '充值页面',
        5 => '赛程页面',
        6 => '好友邀请页面',
        7 => '贵族详情页面',
        8 => '专家发帖页面',
        9 => '签到记录',
    ];


    // 任务类型
    const TYPE_CATE = [
        0 => '日常任务',
        1 => '新手任务',
        //2 => '限时任务',
        3 => '签到任务',
    ];

    // 允许添加的任务
    const TYPE_NAME_ALLOW_ADD = [
        '发送N条弹幕', '订阅N个主播', '给N个主播送礼', '开播N分钟', '分享N个直播间', '观看直播N秒', '观看直播N分钟'
    ];

    // 签到任务配置
    const CHECK_IN_TYPE = [
        1 => '连续签到1天',
        2 => '连续签到2天',
        3 => '连续签到3天',
        4 => '连续签到4天',
        5 => '连续签到5天',
        6 => '连续签到6天',
        7 => '连续签到7天'
    ];

    public function admin()
    {
        return $this->hasOne(AdminModel::class, 'id', 'manager_id');
    }

    public function reward()
    {
        return $this->hasMany(TaskRewardModel::class, 'task_id', 'id');
    }

    public static function getTypeTextAttr($value, $data)
    {
        return static::TYPE_CATE[$data['type']] ?? '';
    }
}